﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using Domain.Entities;

namespace Domain.NetworkService
{
    public class ResolveResult : NetworkTestResult
    {
        HashSet<IPAddress> ips = new HashSet<IPAddress>();
        public string HostName { get; set; }
        public HashSet<IPAddress> Ips
        {
            get { return ips; }
            set { ips = value; }
        }
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("{0} {1} {2}: ", VarDateTime, NetworkTestDescription.NS, HostName);
            if (ips != null)
            {
                foreach (var item in ips)
                {
                    sb.AppendFormat("{0}; ", item);
                }
            }
            else
            {
                sb.AppendFormat(HostName);
            }
            return sb.ToString();
        }
        public override void WriteToDB(string name)
        {
            DBWorker dbw = new DBWorker();
            dbw.WriteTestResult(this, name);
        }

        public override string ToString(ToStringFormatArgs arg)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("{0} {1} {2}: ", VarDateTime, NetworkTestDescription.NS, HostName);
            if (ips != null)
            {
                foreach (var item in ips)
                {
                    sb.AppendFormat(@"{0}; ", item);
                }
            }
            else
            {
                sb.AppendFormat(HostName);
            }
            return sb.ToString();
        }
    }
}
